<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #deng{
            display: flex;
            width: 200px;
            height: 200px;
            background-color: pink;
            border-radius: 50%;
        }
    </style>
</head>
<body>
    <div id="deng"></div>
    <script>
        const box = document.querySelector('#deng')
        let num = 0
        setInterval(function(){
            num += 0.1 
            if(num<2){
                console.log(box.style)
                box.style.backgroundColor = 'red'
            }else if(num < 4){
                box.style.backgroundColor = 'yellow'
            }else if(num < 6){
                box.style.backgroundColor= 'green'
            }else{
                num = 0
            }
        },100)
    </script>
</body>
</html>